package za.ac.wits.was.user.model;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import za.ac.wits.was.courses.Course;
import za.ac.wits.was.courses.allocations.CourseAllocations;
import za.ac.wits.was.disciplines.Discipline;
import za.ac.wits.was.research.ResearchAllocations;

/**
 *
 * @author Salman Noor : School of Electrical and Information Engineering
 * @Copyright: Wits University 2013 - All Rights Reserved
 * @email: salmannoor74415@gmail.com
 * @License: BSD License (http://www.linfo.org/bsdlicense.html)
 */
@Entity
@Table(name = "academic_staff_user")
@DiscriminatorValue("academic_staff")
public class AcademicStaff extends User implements Serializable {

    @Column(name = "academic_user")
    private Boolean academic_user = true;

    @Column(name = "staff_number")
    private String staff_number;
    
    @Column(name = "qualification")
    private String qualification;
    
    @Column(name = "job_position")
    private String job_position;
    
    @Column(name = "contract_type")
    private String contract_type;
    
    @Column(name = "research_percentage")
    private Integer research_percentage;
    
    @Column(name = "teaching_percentage")
    private Integer teaching_percentage;
    
    @Column(name = "citizenship_percentage")
    private Integer citizenship_percentage;
    
    @Column(name = "total_hours")
    private Integer total_hours = 1600;
    
    @ManyToOne
    @JoinColumn(name = "discipline_id")
    private Discipline discipline;
    
    @Transient
    private Long discipline_id;
    
    @Transient
    private String discipline_code;
    
    @Transient
    private String full_descriptive_name;
    
    @OneToMany(mappedBy="academic_staff_member",fetch= FetchType.LAZY)
    private Set<CourseAllocations> course_allocations;
    
    @OneToMany(mappedBy="academic_staff_member",fetch= FetchType.LAZY)
    private Set<ResearchAllocations> research_allocations;
     
    public Boolean getAcademic_user() {
        return academic_user;
    }
    @JsonIgnore
    public void setAcademic_user(Boolean academic_user) {
        this.academic_user = academic_user;
    }

    public String getStaff_number() {
        return staff_number;
    }

    public void setStaff_number(String staff_number) {
        this.staff_number = staff_number;
    }

    public String getQualification() {
        return qualification;
    }

    public void setQualification(String qualification) {
        this.qualification = qualification;
    }

    public String getJob_position() {
        return job_position;
    }

    public void setJob_position(String job_position) {
        this.job_position = job_position;
    }

    public String getContract_type() {
        return contract_type;
    }

    public void setContract_type(String contract_type) {
        this.contract_type = contract_type;
    }

    public Integer getResearch_percentage() {
        return research_percentage;
    }

    public void setResearch_percentage(Integer research_percentage) {
        this.research_percentage = research_percentage;
    }

    public Integer getTeaching_percentage() {
        return teaching_percentage;
    }

    public void setTeaching_percentage(Integer teaching_percentage) {
        this.teaching_percentage = teaching_percentage;
    }

    public Integer getCitizenship_percentage() {
        return citizenship_percentage;
    }

    public void setCitizenship_percentage(Integer citizenship_percentage) {
        this.citizenship_percentage = citizenship_percentage;
    }

    public Integer getTotal_hours() {
        return total_hours;
    }

    public void setTotal_hours(Integer total_hours) {
        this.total_hours = total_hours;
    }
    
    
    @JsonIgnore
    public Discipline getDiscipline() {
        return discipline;
    }
    @JsonIgnore
    public void setDiscipline(Discipline discipline) {
        this.discipline = discipline;
    }
    @JsonProperty("discipline_id")
    public Long getDiscipline_id() {
        if (this.discipline != null){
            this.discipline_id =this.discipline.getDiscipline_id();        
        }
        return this.discipline_id;
    }

    public void setDiscipline_id(Long discipline_id) {
        this.discipline_id = discipline_id;
    }
    @JsonProperty("discipline_code")
    public String getDiscipline_code() {
      if (this.discipline != null){
        this.discipline_code= this.discipline.getDiscipline_code();
      }
        return discipline_code;
    }

    public void setDiscipline_code(String discipline_code) {
        this.discipline_code = discipline_code;
    }
    @JsonIgnore
    public Set<CourseAllocations> getCourse_allocations() {
        return course_allocations;
    }
    @JsonIgnore
    public void setCourse_allocations(Set<CourseAllocations> course_allocations) {
        this.course_allocations = course_allocations;
    }
    @JsonIgnore
    public Set<ResearchAllocations> getResearch_allocations() {
        return research_allocations;
    }
    @JsonIgnore
    public void setResearch_allocations(Set<ResearchAllocations> research_allocations) {
        this.research_allocations = research_allocations;
    }
    @JsonProperty("full_descriptive_name")
    public String getFull_descriptive_name() {
        this.full_descriptive_name = this.getFirstname() + " "+ this.getLastname() +" - "+this.getStaff_number();
        return full_descriptive_name;
    }
    @JsonIgnore
    public void setFull_descriptive_name(String full_descriptive_name) {
        this.full_descriptive_name = full_descriptive_name;
    }
   
    
    
}
